package com.platform.core.service.impl;

import com.platform.comm.service.impl.CommonBizImpl;
import com.platform.core.repository.NcloudSysComponentRepository;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate;
import com.platform.comm.dto.DtoMapper;
import com.platform.core.entity.NcloudSysComponentEntity;
import com.platform.core.entity.QNcloudSysComponentEntity;
import com.platform.core.service.NcloudSysComponentBiz;
import com.platform.dto.NcloudSysComponentDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;


/**
 * Description: NcloudSysComponent-业务接口实现类
 *
 * @author Coder
 */
@Slf4j
@Service
public class NcloudSysComponentBizImpl extends CommonBizImpl<NcloudSysComponentRepository, NcloudSysComponentEntity, String> implements NcloudSysComponentBiz {

    private final QNcloudSysComponentEntity qNcloudSysComponent = QNcloudSysComponentEntity.ncloudSysComponentEntity;
    private final DtoMapper mapper;

    public NcloudSysComponentBizImpl(NcloudSysComponentRepository ncloudSysComponentRepository, DtoMapper mapper) {
        super(ncloudSysComponentRepository);
        this.mapper = mapper;
    }

    @Override
    public Page<NcloudSysComponentDto> search(Predicate predicate, Pageable pageable){
        BooleanBuilder builder = new BooleanBuilder();
        builder.and(qNcloudSysComponent.flag.eq("1"));
        Page<NcloudSysComponentEntity> page = queryByPage(builder, pageable);
        return page.map(entity -> mapper.map(entity, NcloudSysComponentDto.class));
    }

}
